package com.example.testdb1.entity.result;

import lombok.Data;

import java.io.Serializable;

@Data
public class R<T> implements Serializable {

    private Integer code;//状态码 1是成功,0是失败
    private String message;
    private T data;

    public static <T> R<T> success() {
        R<T> r = new R<>();
        r.code = 1;
        return r;
    }

    public static <T> R<T> success(T object) {
        R<T> r = new R<>();
        r.code = 1;
        r.data = object;
        return r;
    }

    public static <T> R<T> error(String message) {
        R<T> r = new R<>();
        r.code = 0;
        r.message = message;
        return r;
    }
}
